﻿/// <reference path="../../../../Scripts/jquery-1.4.1.min-vsdoc.js" />
//页面加载事件
$(document).ready(function () {
    $("#flex1").flexigrid
			(
			{
			    url: 'post2.php',
			    dataType: 'json',
			    colModel: [
				{ display: '文章分类', name: 'CategoryName', width: 100, sortable: true, align: 'center' },
				{ display: '文章标题', name: 'ArticalTitle', width: 180, sortable: true, align: 'left' },
				{ display: '添加日期', name: 'ArticalTitle', width: 120, sortable: true, align: 'left' },
				{ display: '更新日期', name: 'UpdateDate', width: 120, sortable: true, align: 'left' },
				{ display: '添加人', name: 'CreateUser', width: 100, sortable: true, align: 'right' }
				],
			    buttons: [
				{ name: '添加', bclass: 'add', onpress: test },
				{ name: '删除', bclass: 'delete', onpress: test },
				{ separator: true }
				],
			    searchitems: [
				{ display: '文章分类', name: 'CategoryName' },
				{ display: '文章标题', name: 'ArticalTitle', isdefault: true }
				],
			    sortname: "CategoryName",
			    sortorder: "asc",
			    usepager: true,
			    title: '文章列表',
			    useRp: true,
			    rp: 15,
			    showTableToggleBtn: true,
			    width: '98%',
			    height: 200
			}
			);

    function test(com, grid) {
        if (com == '删除') {
            confirm('删除 ' + $('.trSelected', grid).length + ' 项？')
        }
        else if (com == '添加') {
            //alert('添加新项');
            //调用弹出框
            var url = "Insert?height=400&width=520";
            $.fn.colorbox({ href: url, param: {}, title: "添加分类" }, function (data) {
            });
        }
    }

});


